package com.qfedu.edu.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author xiaobobo
 * @title: MyMvcConfig
 * @projectName cd-fy-2401-third-project-parent
 * @description: TODO
 * @date 2024/9/23  15:50
 */
@SpringBootConfiguration
public class MyMvcConfig extends WebMvcConfigurerAdapter {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//       registry.addInterceptor(globalInterceptor).addPathPatterns("/**")
//               .excludePathPatterns("/swagger-ui.html")
//               .excludePathPatterns("/swagger-ui/*")
//               .excludePathPatterns("/swagger-resources/**")
//               .excludePathPatterns("/v2/api-docs")
//               .excludePathPatterns("/v3/api-docs")
//               .excludePathPatterns("/webjars/**");
    }

    /**
     * 静态资源需要从新映射
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
    }
}
